/**
 * Copyright (c) 2005-2016, yinwer81 (yinwer81@aliyun.com)
 *
 * Licensed under the Apache License, Version 2.0
 */
package com.nozturn.throne.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.kisso.common.util.RandomUtil;
import com.nozturn.throne.dao.ClientDao;
import com.nozturn.throne.entity.Client;
import com.nozturn.throne.service.ClientService;

@Transactional
@Service
public class ClientServiceImpl implements ClientService {

    @Autowired
    private ClientDao clientDao;

    public Client createClient(final Client client) {
        /**
         * 这里使用了 32位 UUID ， 当然你可以根据具体业务生成自己的唯一 ID
         */
        client.setClientId(RandomUtil.get32UUID());
        client.setClientSecret(RandomUtil.get32UUID());
        return clientDao.createClient(client);
    }

    public int updateClient(final Client client) {
        return clientDao.updateClient(client);
    }

    public int deleteClient(final Long pk) {
        return clientDao.deleteClient(pk);
    }

    public Client findOne(final Long pk) {
        return clientDao.findOne(pk);
    }

    public List<Client> findAll() {
        return clientDao.findAll();
    }

    public Client findByClientId(final String clientId) {
        return clientDao.findByClientId(clientId);
    }

    public Client findByClientSecret(final String clientSecret) {
        return clientDao.findByClientSecret(clientSecret);
    }

    public List<Client> findByClient(final Client client) {
        return clientDao.findByClient(client);
    }

}
